package com.geline.easytrans.annotation;

import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.geline.easytrans.enums.SensitiveStrategy;
import com.geline.easytrans.serializer.DSMaskedSerializer;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 支持数据脱敏
 * 使用方式：在Entity属性上添加
 *      @DSMasked
 *      @DSMasked(strategy = SensitiveStrategy.FULL)
 *
 * 参考：https://blog.csdn.net/jjc4261/article/details/125410860
 * @author: mengxin
 * @date: 2023/3/13 16:48
 */
@JacksonAnnotationsInside
@JsonSerialize(using = DSMaskedSerializer.class)
@Target({ElementType.TYPE, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface DSMasked {

    //脱敏策略
    SensitiveStrategy strategy() default SensitiveStrategy.AUTO;

    //生成新字段名，显示脱敏值，为空会生成原字段名+Show
    String target() default "";
}
